<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>注册 - HUAWEI Global Store</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {margin:0;padding:0;box-sizing:border-box;}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f9ff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* 背景装饰元素 */
.background-decoration {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.decoration-circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(30, 64, 175, 0.05) 100%);
}

.circle-1 {
    width: 300px;
    height: 300px;
    top: -100px;
    right: -100px;
}

.circle-2 {
    width: 200px;
    height: 200px;
    bottom: 50px;
    left: -50px;
}

.circle-3 {
    width: 150px;
    height: 150px;
    bottom: 200px;
    right: 30%;
}

.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 15px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

.header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.logo-icon {
    margin-right: 10px;
    font-size: 32px;
}

.header a {
    color: white;
    text-decoration: none;
    margin-left: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    padding: 5px 0;
}

.header a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: white;
    transition: width 0.3s ease;
}

.header a:hover::after {
    width: 100%;
}

.register-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.register-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 500px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.register-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
}

.register-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #1e40af, #3b82f6, #60a5fa);
}

.register-box h2 {
    margin-bottom: 30px;
    font-size: 32px;
    color: #1f2937;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
}

.register-box input[type="text"], 
.register-box input[type="email"], 
.register-box input[type="password"],
.register-box input[type="tel"] {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.register-box input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.password-strength {
    margin-top: 8px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.strength-meter {
    height: 100%;
    width: 0;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}

.strength-text {
    font-size: 12px;
    margin-top: 5px;
    text-align: right;
    color: #6b7280;
}

.agreement {
    margin: 20px 0;
    display: flex;
    align-items: flex-start;
    text-align: left;
    font-size: 14px;
    color: #4b5563;
}

.agreement input {
    margin-right: 10px;
    margin-top: 3px;
    accent-color: #3b82f6;
}

.agreement a {
    color: #3b82f6;
    text-decoration: none;
}

.agreement a:hover {
    text-decoration: underline;
}

.register-box .btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.register-box .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.7s ease;
}

.register-box .btn:hover::before {
    left: 100%;
}

.register-box .btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

.divider {
    margin: 25px 0;
    position: relative;
    text-align: center;
    color: #6b7280;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #e5e7eb;
}

.divider span {
    background: white;
    padding: 0 15px;
    position: relative;
    z-index: 1;
}

.social-register {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.social-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.social-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.social-btn.wechat:hover {
    background: #2aae67;
    color: white;
}

.social-btn.qq:hover {
    background: #12b7f5;
    color: white;
}

.social-btn.weibo:hover {
    background: #e6162d;
    color: white;
}

.login-link {
    margin-top: 20px;
    font-size: 15px;
    color: #6b7280;
}

.login-link a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    margin-left: 5px;
    transition: color 0.3s ease;
}

.login-link a:hover {
    color: #1e40af;
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .register-box {
        padding: 30px 25px;
    }
    
    .register-box h2 {
        font-size: 26px;
    }
    
    .header .container {
        flex-direction: column;
        gap: 10px;
    }
    
    .header a {
        margin: 0 10px;
    }
}

/* 错误提示样式 */
.error-message {
    color: #ef4444;
    font-size: 14px;
    text-align: left;
    margin-top: 5px;
    display: none;
}

/* 加载动画 */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s ease infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 注册成功动画 */
.register-success {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.success-content {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: scale(0.9);
    transition: transform 0.5s ease;
}

.success-icon {
    font-size: 60px;
    color: #10b981;
    margin-bottom: 20px;
}

.success-content h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #1f2937;
}

.success-content p {
    color: #6b7280;
    margin-bottom: 20px;
}

.continue-btn {
    padding: 12px 25px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.continue-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

/* 密码显示/隐藏按钮 */
.password-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.password-toggle:hover {
    color: #3b82f6;
}
</style>
</head>
<body>
<!-- 背景装饰元素 -->
<div class="background-decoration">
    <div class="decoration-circle circle-1"></div>
    <div class="decoration-circle circle-2"></div>
    <div class="decoration-circle circle-3"></div>
</div>

<header class="header">
    <div class="container">
        <div class="logo" onclick="window.location.href='index.html'">
            <span class="logo-icon"><i class="fas fa-globe-americas"></i></span>
            HUAWEI Global Store
        </div>
        <div>
            <a href="index.html">首页</a>
            <a href="product-list.html">新品</a>
            <a href="support.html">服务支持</a>
        </div>
    </div>
</header>

<div class="register-container">
    <div class="register-box">
        <h2>用户注册</h2>
        
        <div class="form-group">
            <label for="username">用户名</label>
            <div class="input-group">
                <i class="fas fa-user"></i>
                <input type="text" id="username" placeholder="请输入用户名（3-20个字符）">
            </div>
            <div class="error-message" id="usernameError"></div>
        </div>
        
        <div class="form-group">
            <label for="email">电子邮箱</label>
            <div class="input-group">
                <i class="fas fa-envelope"></i>
                <input type="email" id="email" placeholder="请输入电子邮箱">
            </div>
            <div class="error-message" id="emailError"></div>
        </div>
        
        <div class="form-group">
            <label for="phone">手机号码</label>
            <div class="input-group">
                <i class="fas fa-phone"></i>
                <input type="tel" id="phone" placeholder="请输入手机号码">
            </div>
            <div class="error-message" id="phoneError"></div>
        </div>
        
        <div class="form-group">
            <label for="password">设置密码</label>
            <div class="input-group">
                <i class="fas fa-lock"></i>
                <input type="password" id="password" placeholder="请设置密码（至少6位）">
                <span class="password-toggle" id="passwordToggle">
                    <i class="fas fa-eye"></i>
                </span>
            </div>
            <div class="password-strength">
                <div class="strength-meter" id="strengthMeter"></div>
            </div>
            <div class="strength-text" id="strengthText">密码强度</div>
            <div class="error-message" id="passwordError"></div>
        </div>
        
        <div class="form-group">
            <label for="confirmPassword">确认密码</label>
            <div class="input-group">
                <i class="fas fa-lock"></i>
                <input type="password" id="confirmPassword" placeholder="请再次输入密码">
                <span class="password-toggle" id="confirmPasswordToggle">
                    <i class="fas fa-eye"></i>
                </span>
            </div>
            <div class="error-message" id="confirmPasswordError"></div>
        </div>
        
        <div class="agreement">
            <input type="checkbox" id="agreement">
            <label for="agreement">我已阅读并同意 <a href="#">《用户协议》</a> 和 <a href="#">《隐私政策》</a></label>
        </div>
        <div class="error-message" id="agreementError"></div>
        
        <button class="btn" id="registerButton">注册账号</button>
        
        <div class="divider"><span>或使用以下方式注册</span></div>
        
        <div class="social-register">
            <div class="social-btn wechat">
                <i class="fab fa-weixin"></i>
            </div>
            <div class="social-btn qq">
                <i class="fab fa-qq"></i>
            </div>
            <div class="social-btn weibo">
                <i class="fab fa-weibo"></i>
            </div>
        </div>
        
        <div class="login-link">
            已有账号? <a href="login.html">立即登录</a>
        </div>
    </div>
</div>

<!-- 注册成功提示 -->
<div class="register-success" id="registerSuccess">
    <div class="success-content">
        <div class="success-icon"><i class="fas fa-check-circle"></i></div>
        <h3>注册成功!</h3>
        <p>感谢您注册华为全球商城账号，现在开始探索吧</p>
        <button class="continue-btn" id="continueButton">开始购物</button>
    </div>
</div>

<script>
window.onload = function() {
    const registerButton = document.getElementById('registerButton');
    const usernameInput = document.getElementById('username');
    const emailInput = document.getElementById('email');
    const phoneInput = document.getElementById('phone');
    const passwordInput = document.getElementById('password');
    const confirmPasswordInput = document.getElementById('confirmPassword');
    const agreementCheckbox = document.getElementById('agreement');
    const passwordToggle = document.getElementById('passwordToggle');
    const confirmPasswordToggle = document.getElementById('confirmPasswordToggle');
    const strengthMeter = document.getElementById('strengthMeter');
    const strengthText = document.getElementById('strengthText');
    const registerSuccess = document.getElementById('registerSuccess');
    const continueButton = document.getElementById('continueButton');

    // 错误消息元素
    const errorElements = {
        username: document.getElementById('usernameError'),
        email: document.getElementById('emailError'),
        phone: document.getElementById('phoneError'),
        password: document.getElementById('passwordError'),
        confirmPassword: document.getElementById('confirmPasswordError'),
        agreement: document.getElementById('agreementError')
    };

    // 密码显示/隐藏功能
    passwordToggle.addEventListener('click', function() {
        const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
        passwordInput.setAttribute('type', type);
        this.querySelector('i').classList.toggle('fa-eye');
        this.querySelector('i').classList.toggle('fa-eye-slash');
    });

    confirmPasswordToggle.addEventListener('click', function() {
        const type = confirmPasswordInput.getAttribute('type') === 'password' ? 'text' : 'password';
        confirmPasswordInput.setAttribute('type', type);
        this.querySelector('i').classList.toggle('fa-eye');
        this.querySelector('i').classList.toggle('fa-eye-slash');
    });

    // 密码强度检测
    passwordInput.addEventListener('input', function() {
        const password = this.value;
        let strength = 0;
        let meterColor = '';
        let text = '';
        
        if (password.length > 0) {
            // 长度评分
            if (password.length > 10) strength += 2;
            else if (password.length > 6) strength += 1;
            
            // 字符多样性评分
            if (/[A-Z]/.test(password)) strength += 1;
            if (/[0-9]/.test(password)) strength += 1;
            if (/[^A-Za-z0-9]/.test(password)) strength += 1;
            
            // 设置强度值和显示
            if (strength <= 2) {
                meterColor = '#ef4444'; // 红色
                text = '弱';
            } else if (strength <= 4) {
                meterColor = '#f59e0b'; // 黄色
                text = '中';
            } else {
                meterColor = '#10b981'; // 绿色
                text = '强';
            }
        }
        
        // 更新UI
        strengthMeter.style.width = (strength / 5) * 100 + '%';
        strengthMeter.style.background = meterColor;
        strengthText.textContent = text ? `密码强度: ${text}` : '密码强度';
        strengthText.style.color = meterColor || '#6b7280';
    });

    // 输入验证函数
    function validateInputs() {
        let isValid = true;
        const username = usernameInput.value.trim();
        const email = emailInput.value.trim();
        const phone = phoneInput.value.trim();
        const password = passwordInput.value.trim();
        const confirmPassword = confirmPasswordInput.value.trim();

        // 清空之前的错误信息
        Object.values(errorElements).forEach(el => {
            el.style.display = 'none';
        });

        // 用户名验证
        if (!username) {
            errorElements.username.textContent = '请输入用户名';
            errorElements.username.style.display = 'block';
            isValid = false;
        } else if (username.length < 3 || username.length > 20) {
            errorElements.username.textContent = '用户名长度需在3-20个字符之间';
            errorElements.username.style.display = 'block';
            isValid = false;
        }

        // 邮箱验证
        const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
        if (!email) {
            errorElements.email.textContent = '请输入电子邮箱';
            errorElements.email.style.display = 'block';
            isValid = false;
        } else if (!emailRegex.test(email)) {
            errorElements.email.textContent = '请输入有效的电子邮箱地址';
            errorElements.email.style.display = 'block';
            isValid = false;
        }

        // 手机号验证
        const phoneRegex = /^1[3-9]\d{9}$/;
        if (!phone) {
            errorElements.phone.textContent = '请输入手机号码';
            errorElements.phone.style.display = 'block';
            isValid = false;
        } else if (!phoneRegex.test(phone)) {
            errorElements.phone.textContent = '请输入有效的手机号码';
            errorElements.phone.style.display = 'block';
            isValid = false;
        }

        // 密码验证
        if (!password) {
            errorElements.password.textContent = '请设置密码';
            errorElements.password.style.display = 'block';
            isValid = false;
        } else if (password.length < 6) {
            errorElements.password.textContent = '密码长度不能少于6位';
            errorElements.password.style.display = 'block';
            isValid = false;
        }

        // 确认密码验证
        if (!confirmPassword) {
            errorElements.confirmPassword.textContent = '请确认密码';
            errorElements.confirmPassword.style.display = 'block';
            isValid = false;
        } else if (password !== confirmPassword) {
            errorElements.confirmPassword.textContent = '两次输入的密码不一致';
            errorElements.confirmPassword.style.display = 'block';
            isValid = false;
        }

        // 协议同意验证
        if (!agreementCheckbox.checked) {
            errorElements.agreement.textContent = '请阅读并同意用户协议和隐私政策';
            errorElements.agreement.style.display = 'block';
            isValid = false;
        }

        return isValid;
    }

    // 注册函数
    function performRegistration() {
        if (!validateInputs()) {
            return;
        }

        // 显示加载状态
        registerButton.classList.add('btn-loading');
        
        // 模拟网络请求延迟
        setTimeout(() => {
            // 注册成功
            registerSuccess.style.opacity = '1';
            registerSuccess.style.pointerEvents = 'all';
            document.querySelector('.success-content').style.transform = 'scale(1)';
            
            registerButton.classList.remove('btn-loading');
        }, 1500);
    }

    // 注册按钮点击事件
    registerButton.addEventListener('click', (event) => {
        event.preventDefault();
        performRegistration();
    });

    // 回车键注册
    document.addEventListener('keydown', (event) => {
        if (event.key === 'Enter') {
            performRegistration();
        }
    });

    // 继续按钮点击事件
    continueButton.addEventListener('click', () => {
        window.location.href = 'index.html';
    });

    // 社交注册按钮点击事件（示例）
    document.querySelectorAll('.social-btn').forEach(btn => {
        btn.addEventListener('click', () => {
            alert('该注册方式暂未开放，请使用表单注册');
        });
    });
};
</script>
</body>
</html>